API Documentation
Public Member Functions | Public Attributes | List of all members
nkLog::StringView Class Referencefinal

Allows to exchange strings with external code. More...

Public Member Functions

 StringView ()=delete
 
 StringView (const char *data)
 
 StringView (const char *data, size_t size)
 
 ~StringView ()
 
 StringView (const std::string &str)
 
 StringView (const std::string_view &str)
 
 operator std::string_view () const
 

Public Attributes

const char * _data
 The data pointer over the string.
 
size_t _size
 The string's size.
 

Detailed Description

Allows to exchange strings with external code.

The aim of this class is not to replace any std::string or std::string_view within a code base. It is intended to avoid passing the std templates, or relying on simple pointers when providing string information to logging capabilities. Note that all other components use nkMemory::StringView. However, as nkMemory depends on nkLog, this class has been introduced to help nkLog in this matter. A StringView is offered with many conversion functions, meaning you should never worry about it in the general use-case.

Constructor & Destructor Documentation

◆ StringView() [1/5]

nkLog::StringView::StringView ( )
delete

Default constructor.

◆ StringView() [2/5]

nkLog::StringView::StringView ( const char *  data)

Simple pointer constructor. Will use strlen internally to derive its size.

Parameters
dataThe string pointer to create a view over.

◆ StringView() [3/5]

nkLog::StringView::StringView ( const char *  data,
size_t  size 
)

Pointer and size constructor.

Parameters
dataThe string pointer to create a view over.
sizeThe size of the string passed.

◆ ~StringView()

nkLog::StringView::~StringView ( )

Destructor.

◆ StringView() [4/5]

nkLog::StringView::StringView ( const std::string &  str)

Inlined standard string constructor. This function is inlined and thus will be fed by the client application, correctly addressing the templated class.

Parameters
strThe string to create a view from.

◆ StringView() [5/5]

nkLog::StringView::StringView ( const std::string_view &  str)

Inlined standard string_view constructor. This function is inlined and thus will be fed by the client application, correctly addressing the templated class.

Parameters
strThe view to create a view from.

Member Function Documentation

◆ operator std::string_view()

nkLog::StringView::operator std::string_view ( ) const

Inlined automatic conversion operator. Used to be able to create std::string_views from any client code.


The documentation for this class was generated from the following file: